﻿using DelonixRegia__Staff_Use_.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DelonixRegia__Staff_Use_
{
    public partial class Create_Staff_Account : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label8.Text = Request.QueryString["name"];
            if (Label8.Text == "Admin")
            {
                Label10.Visible = true;
                LinkButton5.Visible = true;
                Label9.Visible = true;
                LinkButton4.Visible = true;
            }
        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            Response.Redirect("StaffWorkTime.aspx?name=" + Label8.Text);
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect("Particulars.aspx?name=" + Label8.Text);
        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            Response.Redirect("StaffUpdate.aspx?name=" + Label8.Text);
        }

        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            Response.Redirect("CreateStaffAccount.aspx?name=" + Label8.Text);
        }

        protected void LinkButton6_Click(object sender, EventArgs e)
        {
            Response.Redirect("CancelBooking.aspx?name=" + Label8.Text);
        }

        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            Response.Redirect("DeleteStaff.aspx?name=" + Label8.Text);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Staff staff = new Staff();
            staff.Name = TextBox4.Text;
            staff.Staffid = TextBox5.Text;
            staff.Ic = TextBox6.Text;
            staff.Age = TextBox7.Text;
            staff.Dob = TextBox8.Text;
            staff.Email = TextBox1.Text;
            staff.Address = TextBox2.Text;
            staff.Contact = TextBox3.Text;
            StaffLogin stafflogin = new StaffLogin();
            stafflogin.Username = TextBox4.Text;
            stafflogin.Password = TextBox9.Text;
            stafflogin.Accounttype = RadioButtonList1.SelectedValue;
            if (Staff.CreateStaff(staff) == 1 && StaffLogin.CreateLogin(stafflogin) == 1)
            {
                Label11.Text = "Successfully Created!";
            }
            else
            {
                Label11.Text = "Unsuccessfully Created!";
            }
        }
    }
}